package com.wds.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wds.mapper.ArticleTagMapper;
import com.wds.domain.entity.ArticleTag;
import com.wds.service.ArticleTagService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 文章标签关联表(ArticleTag)表服务实现类
 *
 * @author wds
 * @since 2022-10-21 15:50:18
 */
@Service("articleTagService")
public class ArticleTagServiceImpl extends ServiceImpl<ArticleTagMapper, ArticleTag> implements ArticleTagService {

    @Override
    public void saveArticleTags(ArrayList<ArticleTag> articleTags) {
        saveBatch(articleTags);
    }

    @Override
    public void removeByArticleIds(List<Long> ids) {
        LambdaUpdateWrapper<ArticleTag> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.in(ArticleTag::getArticleId, ids);
        remove(updateWrapper);
    }

    @Override
    public List<ArticleTag> listByArticleId(Long id) {
        LambdaUpdateWrapper<ArticleTag> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(ArticleTag::getArticleId, id);
        return list(updateWrapper);
    }


}

